package binarySearch;

/**
 * @author le
 */
public class BinarySearch {

    public static void main(String[] args) {
        // 数组
        int[] num = {1,7,9,44,56,100,121,199,233};

        // 执行的次数
        int count = 0;

        int target = 44;

        int low = 0;
        int mid = 0;
        int high = num.length-1;

        while(low <= high){
            mid = (low + high)/2;
            System.out.println("第"+(count+1)+"次,low: "+low+" mid:"+mid+" high: "+high);
            if (target<num[mid]){
                high = mid-1;
                count++;
            }else if(target==num[mid]){
                count++;
                System.out.print("count: "+count+" 值: "+num[mid]);
                break;
            }else{
                low = mid+1;
                count++;
            }
        }


    }
}
